<template>
    <div>       
        <!-- 头部 -->
        <van-nav-bar
            title="不凡"
            left-text="返回"
            @click-left="onClickLeft"
            />
        <div class="newgoods">
                    <div class="banner">
                        <img src="../../../../images/bed.png" alt="">
                    </div>
                    <div class="nav-band">
                            <div class="band" @click="Comprehensive">综合</div>
                            <div class="band" @click="price">价格</div>
                            <div class="band" @click="classification">分类</div>
                    </div>
                    <div class="newgood-list">
                                <div class="listbox" v-for="item in goods" :key="item.id">
                                    <router-link :to="`/goodsinfo?id=${item.id}`">
                                            <img :src="item.list_pic_url" alt="">
                                            <p>{{item.name}}</p>
                                            <p>￥{{item.retail_price}}</p>
                                    </router-link>
                                </div>
                    </div>
                     
        </div>
    </div>
</template>

<script>
import { goodsList } from "../../../api/Home/index.js"
    export default {
        data() {
            return {
                goods:[],
                 isHot:"",
                 isNew:1,
                 order:"desc",
            }
        },
        methods:{
                onClickLeft(){
                    this.$router.go(-1)
                },
                Comprehensive(){
                             goodsList(
                                { 
                                    isHot:this.$route.query.info.isHot,
                                    isNew:this.$route.query.info.isNew,
                                    order:""
                                
                                    }
                                ).then(res=>{
                                         this.goods  =[]
                                        //  console.log(this.goods,"dayingoods");
                                        // console.log(res);
                                        this.goods = res.data
                                        // console.log(this.goods,"赋值后");
                                })
                },
                price(){
                        if(this.order=="desc"){
                            this.order="asc"
                        }else {
                            this.order = "desc"
                        }

                           goodsList(
                                { 
                                    isHot:this.isHot,
                                    isNew:this.isNew,
                                    order:this.order
                                
                                    }
                                ).then(res=>{
                                         this.goods =[]
                                        // console.log(res);
                                        this.goods = res.data
                                      
                                })
                },
                classification(){
                                  goodsList(
                                { 
                                    isHot:this.isHot,
                                    isNew:this.isNew,
                                    order:""
                                
                                    }
                                ).then(res=>{
                                         this.goods  =[]
                                        // console.log(res,"1111");
                                        this.goods = res.data
                                })
                }
        },
        created(){
            goodsList(
               { 
                   isHot:this.isHot,
                   isNew:this.isNew,
                   order:this.order
               
                 }
            ).then(res=>{
                    // console.log(res);
                    this.goods = res.data
            })
        }
    }
</script>

<style lang="scss" scoped>
    .newgoods {
        width: 100%;
        .banner {
            width: 100%;
            height: 139px;
            // background-color: red;
            img {
                width: 100%;
                height: 100%;
            }
        }
        .nav-band{
            width: 100%;
            height: 40px;
            // background-color: green;
            .band {
                width: 3.3333rem;
                height: 100%;
                text-align: center;
                font-size: 12px;
                color: #888;
                float: left;
                line-height: 40px;
                // background-color: blue;
            }
            
        }
        .newgood-list {
                width: 100%;
                display: flex;
                justify-content: space-between;
                align-content: space-around;
                flex-wrap: wrap;
                .listbox {
                            width: 186px;
                            height: 240px;
                            margin-top: 5px;
                            background-color: #fff;
                            img {
                                display: block;
                                width: 151px;
                                height: 151px;
                                margin: 0 auto;
                                // background-color: blue;
                            }
                            :nth-child(2){
                                display: block;
                                width: 100%;
                                font-size: 12px;
                                text-align: center;
                                color: #333;
                            }
                            :nth-child(3){
                                display: block;
                                width: 100%;
                                font-size: 16px;
                                color: #b4282d;
                                text-align: center;
                            }
                        }
              
            }
    }
    
</style>